<script type="text/javascript">
	function doSearchSupplierOfferPrice(value) {
		
	}
	
	//表格查询  
	function reloadSupplierOfferPrice() {
		var params = supplierOfferPrice_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		supplierOfferPrice_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		supplierOfferPrice_list.datagrid('unselectAll');
		supplierOfferPrice_list.datagrid('uncheckAll');
	}


	function addSupplierOfferPrice() {
		createFromWindow("新增信息", "supplierOfferPrice.do?editSupplierOfferPrice", "supplierOfferPrice.do?saveSupplierOfferPrice",
				function(data) {
					reloadSupplierOfferPrice();
				});
	}
	
	function deleteSupplierOfferPrice() {
		var rows = supplierOfferPrice_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('supplierOfferPrice.do?deleteSupplierOfferPriceItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadSupplierOfferPrice();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editSupplierOfferPrice() {
		var rows = supplierOfferPrice_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "supplierOfferPrice.do?editSupplierOfferPrice&supplierOfferPriceId=" + rows[0].id,
					"supplierOfferPrice.do?saveSupplierOfferPrice", function(data) {
						reloadSupplierOfferPrice();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	//操作按钮触发
	function operationsLookSupplierOfferPrice(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = supplierOfferPrice_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "supplierOfferPrice.do?editSupplierOfferPrice&supplierOfferPriceId=" + id,
					null, null,false);
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	function operationsEditSupplierOfferPrice(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = supplierOfferPrice_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("编辑信息", "supplierOfferPrice.do?editSupplierOfferPrice&supplierOfferPriceId=" + id,
					"supplierOfferPrice.do?saveSupplierOfferPrice", function(data) {
						reloadSupplierOfferPrice();
					},true);
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsSendSupplierOfferPrice() {
		printLog('发送');
	}
	
	function operationsDeleteSupplierOfferPrice(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('supplierOfferPrice.do?deleteSupplierOfferPriceItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadSupplierOfferPrice(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
	
	function clearSupplierOfferPriceSearch() {
		setGridSearchParams('supplierOfferPrice_list','supplierOfferPriceSearchForm',true,reloadSupplierOfferPrice);
	}
	
	function createSupplierOfferPrice() {
		var rows = supplierSetPrice_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要重新生成报价单吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('supplierOfferPrice.do?createSupplierOfferPrice',{supplierIds:ids},function(result){
	                    if (result.success){
	                    	reloadSupplierOfferPrice();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请勾选对应客户记录.");
	    }
	}
	
	function sureSupplierOfferPrice() {
		var rows = supplierSetPrice_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	    	if(rows.length>1) {
				showMsg('请选择一条供应商记录进行创建.');
				return;
			}
	        $.messager.confirm('询问','你确认要重新创建报价单吗?',function(r){
	            if (r){
	            	var sureRows = supplierOfferPrice_list.datagrid("getRows"); 
// 	            	printLog(sureRows);
	                $.post('supplierOfferPrice.do?sureSupplierOfferPrice',{data:JSON.stringify(sureRows)},function(result){
	                    if (result.success){
	                    	reloadSupplierOfferPrice();    
	                    }
	                    showMsg(result.msg,2000);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请勾选对应供应商记录.");
	    }
	}
	
	function exportSupplierOfferPrice() {
		var rows = supplierSetPrice_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	    	if(rows.length>1) {
				showMsg('请选择一条客户记录进行创建.');
				return;
			}
	    	printLog(rows);
	    	downLoadFile("supplierOfferPrice.do?exportSupplierOfferPrice&supplierName="+rows[0].name+"&supplierId="+rows[0].id);
	    }else {
	    	showMsg("请勾选对应供应商记录.");
	    }
	}
</script>
<script>
	//根据条件查询
	function supplierOfferPriceSearch() {
		setGridSearchParams('supplierSetPrice_list','supplierSetPriceForm',false,reloadSupplierSetPrice);
	}
	
	function supplierSetPriceSearch() {
		setGridSearchParams('supplierSetPrice_list','supplierSetPriceForm',false,reloadSupplierSetPrice);
	}
	
	function clearSupplierSetPriceSearch() {
		setGridSearchParams('supplierSetPrice_list','supplierSetPriceForm',true,reloadSupplierSetPrice);
	}
	
	//表格查询  
	function reloadSupplierSetPrice() {
		var params = supplierSetPrice_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		supplierSetPrice_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		supplierSetPrice_list.datagrid('unselectAll');
		supplierSetPrice_list.datagrid('uncheckAll');
	}
	

	function onClickSupplierSetPriceItem(rowData) {
		printLog(rowData);
		var params = $('#supplierOfferPrice_list').datagrid('options').queryParams;
		params['supplierId'] = rowData.id;
		//设置好查询参数 reload 一下就可以了 
		$('#supplierOfferPrice_list').datagrid('reload');
	}
</script>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region: 'west', title: '供应商列表',border:false, split: true," style="width: 580px;">
		<@eu.datagrid id="supplierSetPrice_list" toolbar="#supplierSetPrice_search" idField="id"
			 url="supplierInfo.do?loadList" rownumbers="true" onClickRow="onClickSupplierSetPriceItem(rowData)"
			 item="com.xdtech.ad.vo.SupplierInfoItem"/>
		
		<div id="supplierSetPrice_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="supplierSetPriceForm">
					<!-- 防止form表单里只有一个text元素时候，按enter键自动提交问题 -->
					<input style="display:none" />
					<table>
						<tr>
							<td>名称：</td>
							<td><input class="easyui-validatebox textbox" name="name" /></td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="supplierSetPriceSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearSupplierSetPriceSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="supplierSetPrice_toolbar" style="height: auto">
				<@eu.linkbutton showName="刷新" shiro="ad:supplierSetPrice:refresh" iconCls="icon-reload" onclick="reloadSupplierSetPrice()"/>
			</div>
		</div>
		
	</div>
	
	<div data-options="region:'center',border:false,title: '报价列表'">
		<@eu.datagrid id="supplierOfferPrice_list" toolbar="#supplierOfferPricelist_search" idField="id" operations="${operations!}"
			 url="supplierOfferPrice.do?loadList" rownumbers="true" autoEditing="true"
			 item="com.xdtech.ad.vo.SupplierOfferPriceItem"/>
		
		<div id="supplierOfferPricelist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="supplierOfferPriceSearchForm">
					<!-- 防止form表单里只有一个text元素时候，按enter键自动提交问题 -->
					<input style="display:none" />
					<table>
						<tr>
							<td>名称：</td>
							<td><input class="easyui-validatebox textbox" name="name" /></td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="supplierOfferPriceSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearSupplierOfferPriceSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="supplierOfferPrice_toolbar" style="height: auto">
				<@eu.linkbutton showName="生成报价清单" shiro="ad:supplierOfferPrice:createOfferPrice" iconCls="icon-add" onclick="createSupplierOfferPrice()"/>
			
<!-- 				<@eu.linkbutton showName="新增" shiro="ad:supplierOfferPrice:add" iconCls="icon-add" onclick="addSupplierOfferPrice()"/> -->
				<@eu.linkbutton showName="删除" shiro="ad:supplierOfferPrice:delete" iconCls="icon-remove" onclick="deleteSupplierOfferPrice()"/>
<!-- 				<@eu.linkbutton showName="编辑" shiro="ad:supplierOfferPrice:edit" iconCls="icon-edit" onclick="editSupplierOfferPrice()"/> -->
				<@eu.linkbutton showName="创建供应商报价单" shiro="ad:supplierOfferPrice:createOfferPrice" iconCls="icon-add" onclick="sureSupplierOfferPrice()"/>					
				<@eu.linkbutton showName="导出供应商报价单" shiro="ad:supplierOfferPrice:exportOfferPrice" iconCls="icon-add" onclick="exportSupplierOfferPrice()"/>					
				<@eu.linkbutton showName="刷新" shiro="ad:supplierOfferPrice:refresh" iconCls="icon-reload" onclick="reloadSupplierOfferPrice()"/>
				
			</div>
		</div>
	</div>
</div>